import request from '@/utils/request'

/**
 * 搜索接口，已自动筛选生效管理员
 * @param filter 搜索筛选器
 * @param index 第几页
 * @param size 页面大小
 * @returns {AxiosPromise}
 */
export function search(filter, index, size) {
  filter.createUser = 0
  return request({
    url: '/food/searchDefault',
    method: 'post',
    data: {
      filter,
      index,
      size
    }
  })
}

/**
 * 更新接口
 * @param filter 更新筛选器
 * @param update 更新结果
 * @returns {AxiosPromise}
 */
export function update(filter, update) {
  filter.createUser = 0
  return request({
    url: '/food/update',
    method: 'post',
    data: {
      filter,
      update
    }
  })
}

/**
 * 添加接口
 * @param food 新管理员
 * @returns {AxiosPromise}
 */
export function add(food) {
  food.createUser = 0
  return request({
    url: '/food/add',
    method: 'post',
    data: food
  })
}

export function deleted(filter) {
  filter.createUser = 0
  return request({
    url: '/food/delete',
    method: 'post',
    data: {
      filter
    }
  })
}
